<?php session_start();
//  Developed by Roshan Bhattarai 
//  Visit http://roshanbh.com.np for this script and more.
//  This notice MUST stay intact for legal use

// if session is not set redirect the user
if(empty($_SESSION['u_name']))
	header("Location:index.php");	

//if logout then destroy the session and redirect the user
if(isset($_GET['logout']))
{
	session_destroy();
	header("Location:index.php?logout=true");
}	
?>
<?php
$path = "http://".$_SERVER["HTTP_HOST"]."/gibbons";
?>

<?php
include 'includes/header.php';
?>

<table cellpadding="0" cellspacing="0" width="100%" border="0" >
<tr>
<td colspan="2">
<?php
$str = "<a href='home.php?logout' style='text-align:right;'><b>Logout<b></a>";
echo "<div align='right'>Welcome ".$_SESSION['name'].", ".$str."</div>";
?>
</td>
</tr>
<tr>
<td width="15%" valign="top">
<?php
include 'includes/menu.php';
?>
</td>
<td valign="top">
<div id="tabs">

<?php
include 'includes/tabs.php';
?>
<link rel="stylesheet" href="uploadifyit/uploadify.css" type="text/css" />
<!-- Javascript -->
<script type="text/javascript" src="uploadifyit/swfobject.js"></script>
<script type="text/javascript" src="uploadifyit/jquery.uploadify.v2.1.4.min.js"></script>
<script type="text/javascript">
$("#tab2").addClass( "ui-tabs-selected ui-state-active" );
$(document).ready(function() {
	
	//alert('I am ready to use uploadify!');
	$("#file_upload").uploadify({
		'uploader': 'uploadifyit/uploadify.swf',
		'script': 'uploadify.php?id=<?php print $_REQUEST["id"]?>',
		'cancelImg': 'uploadifyit/cancel.png',
		'folder': 'uploads/<?php print $_REQUEST["id"]?>/',
		'auto': true, // use for auto upload
		'multi': true,
		'queueSizeLimit': 10,
		'onQueueFull': function(event, queueSizeLimit) {
			alert("Please don't put anymore files in me! You can upload " + queueSizeLimit + " files at once");
			return false;
		},
		'onComplete': function(event, ID, fileObj, response, data) {
			//alert("Filename: " + fileObj.name + "\nSize: " + fileObj.size + "\nFilepath: " + fileObj.filePath);
			
			// you can use here jQuery AJAX method to send info at server-side.
			//$("#showImages").html("");
			$.ajax({
				type: "POST",
				url: "ajax/subproducts.php",
				data:  "action=showimages&id=<?php print $_REQUEST["id"]?>",
				success: function(data){
					//alert(data);
					$("#showImages").html(data);
				} });	
		}
	});


	
});

</script>

<form id="form1" name="form1" action="">
<table cellpadding="0" width="100%">
<tr>
<td>
<input type="file" id="file_upload" name="file_upload" />
</td>
<td>
<!--<a href="javascript:$('#file_upload').uploadifyUpload();">Upload File</a>
--></td>
</tr>
</table>
</form>

<div id="showImages">
<?php 
	$sql="SELECT * FROM tbl_images WHERE vehicleid=".$_REQUEST["id"];
	$result = mysql_query($sql);
	if(mysql_num_rows($result)>0)
	$str ="<br/>&nbsp;&nbsp;&nbsp;&nbsp;Your Uploaded Images :<br/>";
	else 
	$str ="";
	$str .= "<div style='padding-left:8px'><table>";
	$cnt=0;
	while ($qry = mysql_fetch_array($result)) {
	if($cnt%7== 0)
	$str .= "<tr>";
	$str .= "<td>";
	$str .= "<img src='".$qry["thumbimgpath"]."' />";
	$str .='<br /><a href="javascript:void(0);" onclick="deleteMe('.$qry["id"].','.$_REQUEST["id"].')" >Delete</a>';
	$str .= "</td>";
	if($cnt%7 == 6)
	$str .= "</tr>";
	$cnt++;
	}
	$str .= "</table></div>";
	echo $str;
?>
</div>
</div>
</td>
</tr>
</table>
<?php
include 'includes/footer.php';
?>

